package com.gao.mybatis;

import com.gao.mybatis.configuration.Configuration;
import com.gao.mybatis.parse.SqlMapperConfigXmlParser;
import com.gao.mybatis.resource.ClassPathResources;
import com.gao.mybatis.session.DefaultSqlSessionFactory;
import com.gao.mybatis.session.SqlSession;
import com.gao.mybatis.session.SqlSessionFactory;
import com.gao.mybatis.session.SqlSessionFactoryBuilder;

import java.io.InputStream;
import java.util.List;

/**
 * <p></p>
 *
 * @author GaoShuangWen
 * @since 2020-03-29 22:44
 */
public class Main {
    public static void main(String[] args) throws Exception {
        InputStream inputStream = new ClassPathResources("sqlMapperConfig.xml").getInputStream();
        SqlSessionFactory factory = SqlSessionFactoryBuilder.build(inputStream);
        SqlSession sqlSession = factory.openSession();
        UserDao mapper = sqlSession.getMapper(UserDao.class);

    /*    User user = new User();
        user.setUsername("gao");
        user.setPassword("ww");
        mapper.findUserById(user);*/
        List<User> all = mapper.findAll();
        System.out.println(all);

    }
}
